﻿using System;
using System.Collections.Generic;
using TidyBlog.Entity;
using TidyBlog.Data;

namespace TidyBlog.DAL
{
    /// <summary>
    /// 分类数据层
    /// </summary>
    public class CategoryDAL
    {
        /// <summary>
        /// 创建分类
        /// </summary>
        /// <param name="category">分类</param>
        /// <returns>影响的行数</returns>
        public static int Create(Category category)
        {
            return SimpleORM<Category>.Insert(category);
        }

        /// <summary>
        /// 更新分类
        /// </summary>
        /// <param name="category">分类</param>
        /// <returns>影响的行数</returns>
        public static int Update(Category category)
        {
            return SimpleORM<Category>.Update(category);
        }

        /// <summary>
        /// 删除分类
        /// </summary>
        /// <param name="categoryId">分类Id</param>
        /// <returns>影响的行数</returns>
        public static int Delete(int categoryId)
        {
            return SimpleORM<Category>.Delete(
                new Category()
                {
                    CategoryId = categoryId
                }
            );
        }

        /// <summary>
        /// 读取分类列表
        /// </summary>
        /// <returns>分类列表</returns>
        public static List<Category> List()
        {
            return SimpleORM<Category>.List();
        }
    }
}
